﻿'
'19-10-11 
'Copyright (c) 2011, Yonel Meza Avila
'All rights reserved.
'Liberado bajo licencia New BSD License (BSD) 
'
'
'Dialogo para configuraciones

Imports System.Windows.Forms

Public Class DialogConfig
    'Guarda la configuración
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Dim settings As MySettings = New MySettings
        settings.quipuxserver = UrlTxt.Text
        settings.user = UserTxt.Text
        settings.password = PasswordTxt.Text
        settings.Save()
        MsgBox("Configuración guardada satisfactoriamente")
        Me.Close()
    End Sub
    'No guarda los cambios y cierra el dialogo
    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
    'Carga la forma y los valores actuales
    Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim settings As MySettings = New MySettings
        UserTxt.Text = settings.user
        PasswordTxt.Text = settings.password
        UrlTxt.Text = settings.quipuxserver
    End Sub
    'Reestablece la configuración a la por defecto
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim settings As MySettings = New MySettings
        settings.Reset()
        settings.Save()
        MsgBox("Configuración restaurada")
        UserTxt.Text = settings.user
        PasswordTxt.Text = settings.password
        UrlTxt.Text = settings.quipuxserver
    End Sub
End Class
